package com.sinodata.bsm.center.engine.notify;

import javax.jms.JMSException;

import com.sinodata.bsm.common.message.AsyncSession;
import com.sinodata.notify.center.NotifyMessage;

/**
 * 
 * <p>
 * Description: 通知消息队列初始化与消息发送类
 * </p>
 *
 * @author liulibo
 * @version 1.0

 * <p>
 * History: 
 *
 * Date                     Author         Version     Description
 * ---------------------------------------------------------------------------------
 * 2012-10-24 AM 11:16:56   liulibo        1.0         To create
 * </p>
 *
 * @since 
 * @see
 */
public final class Messenger {

    private static Messenger instance = new Messenger();

    private AsyncSession asynSession = null;

    /**
     * 私有化构造方法
     */
    private Messenger() {

    }

    /**
     * 获取实例
     * 
     * @return
     */
    public static Messenger getInstance() {
        return instance;
    }

    /**
     * 初始化通知消息队列,队列名称为NOTIFY
     */
    public synchronized void init() {
        this.asynSession = new AsyncSession("NOTIFY");
    }

    /**
     * 发送通知消息，抛出JMS异常
     * 
     * @param value
     * @throws JMSException
     */
    public void sendNotify(NotifyMessage notifyMessage) throws JMSException {
        this.asynSession.send(notifyMessage);
    }

}